package com.hunzi.controller;

import com.ramostear.captcha.HappyCaptcha;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

@Controller
public  class HappyCaptchaController {
    //定义一个方法用于显示验证码
    @RequestMapping("/captcha")
    public void createCaptcha(HttpServletRequest request, HttpServletResponse response){
        //使用 Happy Captche 快速生成验证码 length(4)用于设置验证码的长度为4
        HappyCaptcha.require ( request,response ).length ( 4 ).build ().finish ();
    }
}
